import React from "react";
import {Button, Modal, PageHeader} from "antd";
import {
    ExclamationCircleOutlined
} from '@ant-design/icons';

const {Component} = require("react");

export default class Controller extends Component {

    restart(){
        Modal.confirm({
            icon: <ExclamationCircleOutlined />,
            title: '确定要重新开始吗？',
            content: '您确定要重新开始这局游戏吗？您的记录将不会被保存',
            okText: "确定",
            cancelText: "取消",
            onOk:()=> {
                this.props.restart();
            },
            onCancel() {},
        });
    }

    regretChess(){
        Modal.confirm({
            icon: <ExclamationCircleOutlined />,
            title: '确定要悔棋吗？',
            content: '您确定要悔棋吗？',
            okText: "确定",
            cancelText: "取消",
            onOk:()=> {
                this.props.regretChess()
            },
            onCancel() {},
        });
    }

    render() {
        return (
            <div>
                <PageHeader
                    ghost={false}
                    title="五子棋"
                    subTitle="这是一个五子棋的项目"
                    extra={[
                        <Button key="3" type="primary" onClick={this.restart.bind(this)}>重新开始</Button>,
                        <Button key="2" type="default" onClick={this.regretChess.bind(this)}>悔棋</Button>,
                    ]}
                >
                </PageHeader>
            </div>
        );
    }
};